using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace BuddhistSchools.DTO.Models.Mapping
{
    public class SchoolYearMap : EntityTypeConfiguration<SchoolYear>
    {
        public SchoolYearMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("SchoolYear");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.CourseID).HasColumnName("CourseID");

            // Relationships
            this.HasRequired(t => t.Course)
                .WithMany(t => t.SchoolYears)
                .HasForeignKey(d => d.CourseID);

        }
    }
}
